package com.ruoyi.exam.domain.model;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson2.JSON;

public class TestMemory {

   public static Map<Class, Object> map = new HashMap<>();

   public static void main(String[] args) {
      LabelModel labelModel = new LabelModel();
      map.put(labelModel.getClass(), labelModel);
      System.out.println(JSON.toJSONString(InnerTestMemory.labelModel));

      labelModel.setLabel("test1");
      labelModel.setValue("test2");
      System.out.println(JSON.toJSONString(InnerTestMemory.labelModel));
   }

   public static <T> T getObject(Class<T> cls) {
      return (T) map.get(cls);
   }

   private static class InnerTestMemory {
      public static LabelModel labelModel = getObject(LabelModel.class);

   }
}
